<%@ page import="java.util.ArrayList" %>
<%@ page import="com.jf.jsp.Monster" %>
<%@ page import="org.apache.jasper.runtime.HttpJspBase" %>
<%--
  Created by IntelliJ IDEA.
  User: 22954
  Date: 2024/8/30
  Time: 16:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>脚本</title>
</head>
<body>
<%--声明脚本'<%! %>'  用来声明类属性/方法/静态属性--%>
<%!
    int age = 18;
    String sex = "female";
    ArrayList<Monster> monsters = new ArrayList<>();

    public String getSex() {
        return sex;
    }
%>

<%--表达式脚本'<%= %>'  用来获取数据并输出在jsp页面--%>
<h3>age:<%=age%>
</h3>
<h3>sex:<%=getSex()%>
</h3>


<%--代码脚本'<% %>'  用于编写java代码,由所有脚本代码组合完成java程序--%>
<%
    out.println("hello world");
    monsters.add(new Monster("牛魔王", "蛮牛冲撞"));
    monsters.add(new Monster("铁扇公主", "芭蕉扇"));
%>

<table bgcolor="aqua" border="1px" width="300px">
    <tr>
        <th>id</th>
        <th>name</th>
        <th>skill</th>
    </tr>
    <%
        for (int i = 0; i < monsters.size(); i++) {
            Monster monster = monsters.get(i);
    %>
    <tr>
        <td><%=i + 1%></td>
        <td><%=monster.getName()%></td>
        <td><%=monster.getSkill()%></td>
    </tr>
    <%
        }
    %>
</table>
</body>
</html>
